home *** CD-ROM | disk | FTP | other *** search
- #!/bin/sh
- # fadd - file add script
- # copyright (c) 2000, joseph cheek, joseph@redmondlinux.org
- # released under gpl.
- #
- # $1: full pathname of added file
- # $2: directory [inside buildroot] to place file
- # ex: fup /home/joseph/myfile col/devel
- #
- # opts: -q: quiet [don't print status messages]
- # -f: force [update even when older]
- # -l: language to add to [default: all languages]
-
- # BUG: use getopts instead
- LANG=
- ERROR=0
-
- if [ "n$1" = "n-q" ]; then # -q
- QUIET="-q"
- shift
- fi
-
- if [ "n$1" = "n-f" ]; then # -f
- FORCE="(force)"
- shift
- fi
-
- if [ "n$1" = "n-l" ]; then # -l
- LANG="$2"
- shift
- shift
- fi
-
- if [ ! -r "$1" ]; then # file doesn't exist
- ( echo `basename $0`: can\'t find \"$1\"
- echo
- echo usage: `basename $0` \[-q\] \[-f\] \[-l lang\] file dir
- echo adds file to dir of redmond linux build system
- echo -q is quiet, ie don\'t print status messages
- echo -f is force, ie add even if added file is older
- echo -l is language or all if not present ) >&2
- exit 1
- fi
-
- if [ $# -lt 2 ]; then # no dir given
- ( echo `basename $0`: no dir given
- echo perhaps you wanted padd?
- echo
- echo usage: `basename $0` \[-q\] \[-f\] \[-l lang\] file dir
- echo adds file to dir of redmond linux build system
- echo -q is quiet, ie don\'t print status messages
- echo -f is force, ie add even if added file is older
- echo -l is language or all if not present ) >&2
- exit 1
- fi
-
- # constants and vars
-
- RL_ROOT=/opt/redmondlinux
- BUILD_NUM_FILE=$RL_ROOT/builds/CURRENT_BUILD
- BUILD_NUM=`cat $BUILD_NUM_FILE`
- BUILD_ROOT=$RL_ROOT/builds/$BUILD_NUM
-
- BASENAME=`basename "$1"`
-
- cd $BUILD_ROOT
- LANG_TO_PROCESS=`echo ${LANG}*`
- cd -
-
- for lang in $LANG_TO_PROCESS; do
-
- CHANGELOG=$BUILD_ROOT/$lang/CHANGELOG
- ADDED_FILE="$BUILD_ROOT/$lang/$2/$BASENAME"
-
-
- # more error checks
-
- if [ ! -d $BUILD_ROOT/$lang/"$2" ]; then # dir doesn't exist
- ( echo `basename $0`: can\'t find \"$BUILD_ROOT/$lang/$2\"
- echo
- echo usage: `basename $0` \[-q\] \[-f\] \[-l lang\] file dir
- echo adds file to dir of redmond linux build system
- echo -q is quiet, ie don\'t print status messages
- echo -f is force, ie add even if added file is older
- echo -l is language or all if not present ) >&2
- ERROR=1
- fi
-
- if [ -f "$ADDED_FILE" ]; then # added file already exists
- ( echo `basename $0`: already found \"$ADDED_FILE\"
- echo perhaps you need to update it, not add it ) >&2
- ERROR=1
- fi
-
-
- # perform the add
-
- cp -f "$1" "$ADDED_FILE"
-
- if [ "$?" -gt 0 ]; then # file copy failed
- ( echo `basename $0`: copy failed
- echo please check permissions and try again ) >&2
- ERROR=1
- fi
-
-
- # update changelog
-
- echo + "$2/$BASENAME" >> $CHANGELOG
-
- if [ "$?" -gt 0 ]; then # update changelog failed
- ( echo `basename $0`: update changelog failed
- echo check permissions on $CHANGELOG ) >&2
- ERROR=1
- fi
-
- [ $QUIET ] || tail -n 1 $CHANGELOG
-
- done
-
- exit $ERROR
-